package com.car.ljc.scheduler;

import com.car.ljc.entity.Car;
import com.car.ljc.entity.PakingLot;
import com.car.ljc.util.CommonUtil;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 调度
 * @Author ljc
 * @Date 2018/9/20 11:37
 */
@Component
@ConfigurationProperties(prefix = "car")
public class SchedulerTask {
    private static String[] tokens={};
    private boolean init = false;
    private List<PakingLot> pakingLotList = new ArrayList<>();
    @Scheduled(fixedDelay = 1000)
    public void  process(){
        /*if(!init){
            init();
        }
        for (PakingLot pakingLot:pakingLotList) {
            pakingLot.syns();
        }*/
        init();
    }

    public String[] getTokens() {
        return tokens;
    }

    public void setTokens(String[] tokens) {
        this.tokens = tokens;
    }

    /**
     * 初始化
     * @return
     */
    private void init(){
        for(String token : tokens){
            //初始化状态
            PakingLot pakingLot = new PakingLot();
            pakingLot.setToken(token);
            pakingLot.init();
            pakingLot.syns();
           /* init = true;
            pakingLotList.add(pakingLot);*/
        }
    }
    public static void main(String[] args) {
        //System.out.println(CommonUtil.get("https://s395.kxtoo.com/10_105_205_7/7301//game?cmd=enter&token=32594d9028c394a0b24365e4074c9558&now="+longTime()+"&inviteId=undefined&cp_from=undefined&cp_link=undefined&cp_shareId=0"));
    }
}
